﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FriendAD.Core
{
   public class AdManager:BaseManager<Ad>
    {
        public IQueryable<Ad> getUserAd(string username)
        {
            User _user = new UserManager().Find(u => u.UserName == username);
            return FindList(user => user.UserId == _user.UserID&&user.isDel==false);
        }
        /// <summary>
        /// 检测广告合法性
        /// </summary>
        /// <param name="adid"></param>
        /// <param name="username"></param>
        /// <returns></returns>
        public bool CheckAd(int adid,string username)
        {
            User _user = new UserManager().Find(u => u.UserName == username);
            return Exits(ad => ad.AdID == adid && ad.UserId == _user.UserID);
        }
    }
}
